package QHgui.docing;

import QHgui.QHMainFrame;
import SingleService.SingleInstance;
import SingleService.SingleInstanceKey;
import com.javadocking.component.DefaultSwComponentFactory;

import javax.swing.*;
import java.awt.*;

/**
 * <p> TODU </P>
 *
 * @author yeager
 * @Version V1.1.1.0
 * @date 2023/11/24 10:41
 */
public class SampleComponentFactory extends DefaultSwComponentFactory {
    /** The default size of the divider for splitpanes. */
    public static final int DEFAULT_DIVIDER_SIZE = 3;

    // Fields.

    /** The size of the divider for splitpanes. */
    private int dividerSize = DEFAULT_DIVIDER_SIZE;

    // Overwritten methods of DefaultSwComponentFactory.

    public JSplitPane createJSplitPane()
    {

        JSplitPane splitPane = super.createJSplitPane();
        splitPane.setDividerSize(dividerSize);
        return splitPane;

    }
    public JTabbedPane createJTabbedPane()
    {
        JTabbedPane pane=super.createJTabbedPane();
        //System.out.println("createJTabbedPane");
        QHMainFrame mf=(QHMainFrame) SingleInstance.getInstance(SingleInstanceKey.MainFrame);
        if(mf!=null)
        {
            if(mf.getWorkingPanel()!=null)
            {
                //pane.addChangeListener(mf.getWorkingPanel());
            }
        }
        return pane;
    }

    // Getters / Setters.

    /**
     * Gets the size of the divider for split panes.
     *
     * @return				The size of the divider for split panes.
     */
    public int getDividerSize()
    {
        return dividerSize;
    }

    /**
     * Sets the size of the divider for split panes.
     *
     * @param dividerSize	The size of the divider for split panes.
     */
    public void setDividerSize(int dividerSize)
    {
        this.dividerSize = dividerSize;
    }
    /**
     * Creates an undecorated non-modal dialog that is resizable.
     */
    public JDialog createJDialog(Window owner)
    {

        // Create the dialog.
        JDialog.setDefaultLookAndFeelDecorated(false);
        JDialog dialog=super.createJDialog(owner);
        dialog.setUndecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(false);
        return dialog;
    }

}
